using System;

namespace App.Practice.Step02
{
   public class Demo
   {
      public static void Run()
      {
         Copier.ptFlag = true;
         Copier.Copy();
      }
   }

   internal static class Copier
   {
      // Write a program that copies characters from the keyboard to the printer.
      // Should now also be able to read from the paper tape reader.
      //    Cannot change the interface

      public static bool ptFlag;

      public static void Copy()
      {
         char c;
         while (Char.ToLower(c = (ptFlag ? PaperTape.Read() : Keyboard.Read())) != 'x')
            Printer.Write(c);
      }
   }

   internal static class Keyboard
   {
      public static char Read()
      {
         return Console.ReadKey().KeyChar;
      }
   }

   internal static class Printer
   {
      public static void Write(char c)
      {
         Console.Write(c);
      }
   }

   internal static class PaperTape
   {
      public static char Read()
      {
         return char.ToUpper(Console.ReadKey().KeyChar);
      }
   }
}